﻿using System.Collections.Generic;
using Aquarinum.Base.Infrastructure.Ioc;
using Aquarinum.Base.Infrastructure.WebSocket.InterfaceImp;
using Aquarinum.Base.Service.Http;
using Microsoft.AspNetCore.Mvc;

namespace Aquarinum.WebSocket.Server.Controllers
{
    [Route("Api/WebSocket/Client")]
    public class ClientController : AquarinumApiController
    {
        /// <summary>
        ///     获取所有在线客户端列表
        /// </summary>
        /// <returns></returns>
        [HttpGet("GetAllClient")]
        public IList<string> GetAllClient()
        {
            var conntainer = AquainumContainer.Resolve<WebSocketConnectionContainer>();
            return conntainer.GetAllClient();
        }

        /// <summary>
        ///     客户端是否在线
        /// </summary>
        /// <returns></returns>
        [HttpGet("CheckClientConnected")]
        public bool CheckClientConnected(string clientid)
        {
            var conntainer = AquainumContainer.Resolve<WebSocketConnectionContainer>();
            return conntainer.CheckClientExist(clientid);
        }
    }
}